<?php
/**
 *
 * Show the product details page
 *
 * @package	VirtueMart
 * @subpackage
 * @author Max Milbers, Eugen Stranz
 * @author RolandD,
 * @todo handle child products
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 6530 2012-10-12 09:40:36Z alatak $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// addon for joomla modal Box
JHTML::_('behavior.modal');






// JHTML::_('behavior.tooltip');
$printL = JRequest::getVar('print', 0);
$document = JFactory::getDocument();
$document->addScriptDeclaration("
//<![CDATA[
	jQuery(document).ready(function($) {
		$('a.ask-a-questionbkm').click( function(){
			
			var wwidth = $(window).width();
			if(wwidth<767){
				window.location.href = '".$this->askquestion_url."';
			}else{
		
				$.facebox({
					iframe: '" . $this->askquestion_url . "',
					rev: 'iframe|630|700'
				});
			}
			
			return false ;
		});

	});
//]]>
");

if($printL):
	$document->addScriptDeclaration("
	//<![CDATA[
		jQuery(document).ready(function($) {
			window.print();
	
		});
	//]]>
	");
endif;

/* Let's see if we found the product */
if (empty($this->product)) {
    echo JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
    echo '<br /><br />  ' . $this->continue_link_html;
    return;
}
?>

<div class="container-fluid">
	

	
	<div class="row-fluid">
		<div class="span12">
			    <?php
			    // PDF - Print - Email Icon
			    if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_button_enable')) {
				?>
			        <div class="pull-right">
				    <?php
				    //$link = (JVM_VERSION===1) ? 'index2.php' : 'index.php';
				    $link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id;
				    $MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component';
			
				    if (VmConfig::get('pdf_icon', 1) == '1') {
					?>
					<a href="<?php echo $link. '&format=pdf';?>" title="PDF" target="_blank">
						<img alt="PDF" src="media/system/images/pdf_button.png">
					</a>
					<?php
				    }/*
				    ?>
				    <a href="<?php echo $link. '&print=1';?>" title="Print" target="_blank">
						<img alt="Print" src="media/system/images/printButton.png">
					</a>
				    <?php */
				    echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend');
				    ?>
			        </div>
			    <?php } ?>			
			
			 
			 <?php // afterDisplayTitle Event
			     echo $this->product->event->afterDisplayTitle ?>
			 <?php
			    // Product Edit Link
			    echo $this->edit_link;
			    ?>   		

		    
		</div>
		
	</div>
	
	
	<div class="row-fluid">
		<div class="span5">
			<?php
				echo $this->loadTemplate('images');
			?>
		</div>
		
		
		<div class="span7">

		
		
   <div class="spacer-buy-area well">
	   		<h2 class="titleProductInfo"><?php echo $this->product->product_name ?></h2>
	   		
	   		<div class="product-short-description">
	   		<p class="articNum"><?php echo JText::_('COM_VIRTUEMART_MAIL_ITEMID');?>: <?php echo $this->product->product_sku ?></p>

	   		
	   		
		    <?php
		    // Product Short Description
		    if (!empty($this->product->product_s_desc)) {
			?>
		        
		        <p class="articNum"><strong><?php echo JText::_('COM_VIRTUEMART_CART_DESC');?></strong></p>
			    <?php
			    /** @todo Test if content plugins modify the product description */
			    echo nl2br($this->product->product_s_desc);
			    ?>
		       
		        <hr />
			<?php
		    } // Product Short Description END
		    ?>
			 </div>

		<?php
		if ($this->showRating) {
		    $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);

		    if (empty($this->rating)) {
			?>
			<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' . JText::_('COM_VIRTUEMART_UNRATED') ?></span>
			    <?php
			} else {
			    $ratingwidth = $this->rating->rating * 24; //I don't use round as percetntage with works perfect, as for me
			    ?>
			<span class="vote">
	<?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' . round($this->rating->rating) . '/' . $maxrating; ?><br/>
			    <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . round($this->rating->rating) . '/' . $maxrating) ?>" class="ratingbox" style="display:inline-block;">
				<span class="stars-orange" style="width:<?php echo $ratingwidth.'px'; ?>">
				</span>
			    </span>
			</span>
			<?php
		    }
		}
		if (is_array($this->productDisplayShipments)) {
		    foreach ($this->productDisplayShipments as $productDisplayShipment) {
			echo $productDisplayShipment . '<br />';
		    }
		}
		if (is_array($this->productDisplayPayments)) {
		    foreach ($this->productDisplayPayments as $productDisplayPayment) {
			echo $productDisplayPayment . '<br />';
		    }
		}
		// Product Price
		    // the test is done in show_prices
		//if ($this->show_prices and (empty($this->product->images[0]) or $this->product->images[0]->file_is_downloadable == 0)) {
		    echo $this->loadTemplate('showprices');
		//}
		?>

		<?php
		// Add To Cart Button
// 			if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
//		if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices['salesPrice'])) {
		    echo $this->loadTemplate('addtocart');
//		}  // Add To Cart Button END
		?>
		<p class="infoAddtoCart"><?php echo JText::_('COM_VIRTUEMART_INFOADDTOCART') ?></p>
		<?php
		// Availability Image
		$stockhandle = VmConfig::get('stockhandle', 'none');
		if (($this->product->product_in_stock - $this->product->product_ordered) < 1) {
			if ($stockhandle == 'risetime' and VmConfig::get('rised_availability') and empty($this->product->product_availability)) {
			?>	<div class="availability">
			    <?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability'))) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability', '7d.gif'), VmConfig::get('rised_availability', '7d.gif'), array('class' => 'availability')) : VmConfig::get('rised_availability'); ?>
			</div>
		    <?php
			} else if (!empty($this->product->product_availability)) {
			?>
			<div class="availability">
			<?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . $this->product->product_availability)) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $this->product->product_availability, $this->product->product_availability, array('class' => 'availability')) : $this->product->product_availability; ?>
			</div>
			<?php
			}
		}
		?>

<?php
// Ask a question about this product
if (VmConfig::get('ask_question', 1) == 1) {
    ?>

		<?php }
		?>

		<?php
		// Manufacturer of the Product
		if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
		    echo $this->loadTemplate('manufacturer');
		}
		?>
		<?php 
	    if (!empty($this->product->customfieldsSorted['ontop'])) {
			$this->position = 'ontop';
			echo $this->loadTemplate('customfields');
	    } // Product Custom ontop end
	    ?>
		<?php
	
	    if (!empty($this->product->customfieldsSorted['normal'])) {
		$this->position = 'normal';
		echo $this->loadTemplate('customfields');
	    } // Product custom_fields END
	    // Product Packaging
	    $product_packaging = '';
	    if ($this->product->product_box) {
		?>
	        <div class="product-box">
		    <?php
		        echo JText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
		    ?>
	        </div>
	    <?php } // Product Packaging END
	    ?>	    
	    
	    
	    
	    
<a class="ask-a-questionbkm btn btn-small btn-info" rel="mobext" href="<?php echo $this->askquestion_url ?>" ><i class="icon-info-sign icon-white"></i> <?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
	<div class="clear"></div>		    
	    
	    </div>
	</div>

		
</div>
	
	<div class="row-fluid" id="bkm_product_description">
		<div class="span12">
			<?php
			// Product Description
			if (!empty($this->product->product_desc)) {
			    ?>
		        <div class="product-description">
			<?php /** @todo Test if content plugins modify the product description */ ?>
		    	<h3><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE') ?></h3>
			<?php echo $this->product->product_desc; ?>
		        </div>
			<?php
		    } // Product Description END
		    ?>
				<?php // event onContentBeforeDisplay
				echo $this->product->event->beforeDisplayContent; ?>
				
				
			
				
		</div>
	</div>
	
	
	<div class="row-fluid" id="bkm_product_reviews">
		<div class="span12">
			<?php
				echo $this->loadTemplate('reviews');
				?>			
		</div>
	</div>


	<div class="row-fluid" id="bkm_product_extrainfo">
		<div class="span12">
		    <?php
		    if (!empty($this->product->customfieldsSorted['onbot'])) {
		    	$this->position='onbot';
		    	echo $this->loadTemplate('customfields');
		    } // Product Custom ontop end
		    ?>
		
			<?php // onContentAfterDisplay event
			echo $this->product->event->afterDisplayContent; ?>	
		</div>
	</div>
	
	
	<div class="row-fluid" id="relatedProducts">
		<div class="span12">
		<?php
		    if (!empty($this->product->customfieldsRelatedProducts)) {
				echo $this->loadTemplate('relatedproducts');
		    } // Product customfieldsRelatedProducts END

		?>
		</div>
	</div>
	
</div>



   






